import matplotlib.pyplot as plt
import pandas as pd
df=pd.read_excel('学生各学期成绩表.xlsx')
plt.figure(figsize=(10,8))
plt.rcParams['font.sans-serif']='SimHei'
plt.title('学生各学期成绩分析')
plt.xlabel('学期')
plt.ylabel('成绩')
x=df['序号']
y=df['语文']
m=df['英语']
n=df['数学']
v=df['综合']
plt.subplot(2,2,1)
for a, b in zip(df['序号'],df['语文']):
    plt.text(a,b,'%.1f'%b,ha='center')
plt.grid(axis='both')
plt.xticks(range(11),df['序号'],rotation=15)
plt.plot(x,y,'--')
plt.legend(('语文',))

plt.subplot(2,2,2)
for a, b in zip(df['序号'],df['数学']):
    plt.text(a,b,'%.1f'%b,ha='center')
plt.grid(axis='both')
plt.xticks(range(11),df['序号'],rotation=15)
plt.plot(x,n,'g-.o')
plt.legend(('数学',))

plt.subplot(2,2,3)
for a, b in zip(df['序号'],df['英语']):
    plt.text(a,b,'%.1f'%b,ha='center')
plt.grid(axis='both')
plt.xticks(range(11),df['序号'],rotation=15)
plt.plot(x,m,'c-^')
plt.legend(('英语',))

plt.subplot(2,2,4)
for a, b in zip(df['序号'],df['综合']):
    plt.text(a,b,'%.1f'%b,ha='center')
plt.grid(axis='both')
plt.xticks(range(11),df['序号'],rotation=15)
plt.plot(x,v,'r:d')
plt.legend(('综合',))
plt.show()
